package com.ljfiction.book.Dialog;

import android.app.Dialog;
import android.content.Context;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;

import com.ljfiction.book.R;

/**
 * Created by Android on 2017/11/29.
 */

public class LoadingDIalog {
    private Dialog mDialog;
    private Context mcontext;

    public LoadingDIalog(Context context) {
        this.mcontext=context;
        mDialog = new Dialog(mcontext, R.style.AppTheme3);
        View view= LayoutInflater.from(mcontext).inflate(R.layout.dialog_loading, null);
        //将布局设置给Dialog
        mDialog.setContentView(view);
        ViewGroup.LayoutParams layoutParams = view.getLayoutParams();
        layoutParams.width = mcontext.getResources().getDisplayMetrics().widthPixels;
        view.setLayoutParams(layoutParams);
        mDialog.getWindow().setGravity(Gravity.CENTER);
        mDialog.getWindow().setWindowAnimations(R.style.ActionSheetDialogAnimation);

        mDialog.setCanceledOnTouchOutside(false);
        //mDialog.setCancelable(false);
    }
    public void show() {
        if (mDialog != null) {
            mDialog.show();
        }
    }
    public void  dismis(){
        if (mDialog != null) {
            mDialog.dismiss();
        }
    }
}
